/*
 * @Description:
 * @Autor: ZY
 * @Date: 2020-12-07 10:30:20
 * @LastEditors: ycw
 * @LastEditTime: 2022-01-30 16:04:17
 */
import { createApp, Directive } from 'vue'
import App from './App.vue'
// import './pwa/registerServiceWorker'
import router from './router'
import { store } from './store'
import { getConfigKey } from "@/apis/system/config";
import { loadAllPlugins } from './plugins'
import '@/assets/iconfont/iconfont.css'
import '@/styles/index.scss'
import '@/styles/ruoyi.scss' // ruoyi css
import 'normalize.css'
import * as directives from '@/directives'
import '@/permission'
import { getDicts } from "@/apis/system/dict/data";
import { download } from '@/utils/https';
import { parseTime, resetForm, addDateRange, selectDictLabel, handleTree } from '@/utils/ruoyi'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
const app = createApp(App)
// 全局方法挂载
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.getConfigKey = getConfigKey
app.config.globalProperties.download = download
app.config.globalProperties.getDicts = getDicts
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success" });
}

app.config.globalProperties.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: "error" });
}
app.use(ElementPlus, {
  locale: zhCn,
})
app.config.globalProperties.msgInfo = function (msg) {
  this.$message.info(msg);
}

// 加载所有插件
loadAllPlugins(app)

console.log(process.env.VUE_APP_BASE_API)
app.use(store).use(router).mount('#app')
// 自定义指令
Object.keys(directives).forEach(key => {
  app.directive(key, (directives as { [key: string ]: Directive })[key])
})


